package org.jumiz.telnet.command;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 *
 */
public enum CommandEnum {

    QUIT("q", "退出"),
    ;

    private String command;
    private String desc;

    CommandEnum(String command, String desc) {
        this.command = command;
        this.desc = desc;
    }

    public String getCommand() {
        return command;
    }

    public String getDesc() {
        return desc;
    }

    public static CommandEnum command(String command) {
        List<CommandEnum> commandEnums =
                Arrays.stream(CommandEnum.values())
                        .filter(item -> item.getCommand().equalsIgnoreCase(command))
                        .collect(Collectors.toList());
        if (commandEnums != null && commandEnums.size() > 0) {
            return commandEnums.get(0);
        }
        return null;
    }

}
